package com.xiepei.day01;

public class Person {
    private String name;
    private int age;
    private String gender;

    //构造方法
    public Person(String name, int age, String gender) {
        setName(name);
        setAge(age);
        setGender(gender);
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        if(age> 0 && age <120){
            this.age = age;
        }else {
            System.out.println("年龄输入错误！");
        }
    }

    public void setGender(String gender) {
        this.gender = gender;
    }
    
    // Getter方法
    public String getName() {
        return name;
    }
    
    public int getAge() {
        return age;
    }
    
    public String getGender() {
        return gender;
    }

    public void displayInfo() {
        System.out.println("姓名：" + name + "，年龄：" + age + "，性别：" + gender);
    }



}


